package com.hsxshop.serviceimpl;

import com.hsxshop.dao.BaseDao;
import com.hsxshop.model.Pagination;
import com.hsxshop.model.Supply;
import com.hsxshop.service.BaseService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by wangchongya on 17/5/8.
 */

public abstract class BaseServiceImpl<T> implements BaseService<T>{

    private BaseDao<T> dao;

    public BaseDao<T> getDao() {
        return dao;
    }

    public void setDao(BaseDao<T> dao) {
        this.dao = dao;
    }

    public int saveEntity(T t) {
        return dao.saveEntity(t);
    }

    public void updateEntity(T t) {
        dao.updateEntity(t);
    }

    public void saveOrUpdateEntity(T t) {
        dao.saveOrUpdateEntity(t);
    }

    public void deleteEntity(T t) {
        dao.deleteEntity(t);
    }

    public T getEntity(Integer id) {
        return dao.getEntity(id);
    }
    public T getEntity(String hql, Object... objects){
        return dao.getEntity(hql,objects);
    }
    public Map getMapByHQL(String hql, Object... objects){
        return dao.getMapByHQL(hql,objects);
    }
    public List<Map> getListMapByHQL(String hql, Object... objects){
        return dao.getListMapByHQL(hql,objects);
    }
    /** 注意FROM 必须为大写 **/
    public List<Map> getListMapByHQL(Pagination pagination,String hql, Object... objects){
        return dao.getListMapByHQL(pagination,hql,objects);
    }
    public List<T> findByHQL(String hql, Object... objects) {
        return dao.findByHQL(hql,objects);
    }
    public boolean exitsByHQL(String hql, Object... objects){
        return dao.exitsByHQL(hql,objects);
    }
    public int execHQL(String hql, Object... objects) {
        return  dao.execHQL(hql,objects);
    }
    public int getRowsCountByHQL(String hql, Object... objects){
        return dao.getRowsCountByHQL(hql,objects);
    }
    public List<T> findByHQLWithPagination(Pagination pagination, String sql, Object... objects){
        return dao.findByHQLWithPagination(pagination,sql,objects);
    }
}
